package com.app.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.app.common.annotation.Log;
import com.app.common.core.controller.BaseController;
import com.app.common.core.domain.AjaxResult;
import com.app.common.core.page.TableDataInfo;
import com.app.common.enums.BusinessType;
import com.app.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.app.biz.domain.BizAppDataReport;
import com.app.biz.service.IBizAppDataReportService;


/**
 * 数据报告Controller
 * 
 * @author ruoyi
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/system/report")
public class BizAppDataReportController extends BaseController
{
    @Autowired
    private IBizAppDataReportService bizAppDataReportService;

    /**
     * 查询数据报告列表
     */
    //@PreAuthorize("@ss.hasPermi('system:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizAppDataReport bizAppDataReport)
    {
        startPage();
        List<BizAppDataReport> list = bizAppDataReportService.selectBizAppDataReportList(bizAppDataReport);
        return getDataTable(list);
    }

    /**
     * 导出数据报告列表
     */
    //@PreAuthorize("@ss.hasPermi('system:report:export')")
    @Log(title = "数据报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizAppDataReport bizAppDataReport)
    {
        List<BizAppDataReport> list = bizAppDataReportService.selectBizAppDataReportList(bizAppDataReport);
        ExcelUtil<BizAppDataReport> util = new ExcelUtil<BizAppDataReport>(BizAppDataReport.class);
        util.exportExcel(response, list, "数据报告数据");
    }

    /**
     * 获取数据报告详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:report:query')")
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(bizAppDataReportService.selectBizAppDataReportByBaseId(baseId));
    }

    /**
     * 新增数据报告
     */
    //@PreAuthorize("@ss.hasPermi('system:report:add')")
    @Log(title = "数据报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizAppDataReport bizAppDataReport)
    {
        return toAjax(bizAppDataReportService.insertBizAppDataReport(bizAppDataReport));
    }

    /**
     * 修改数据报告
     */
    //@PreAuthorize("@ss.hasPermi('system:report:edit')")
    @Log(title = "数据报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizAppDataReport bizAppDataReport)
    {
        return toAjax(bizAppDataReportService.updateBizAppDataReport(bizAppDataReport));
    }

    /**
     * 删除数据报告
     */
    //@PreAuthorize("@ss.hasPermi('system:report:remove')")
    @Log(title = "数据报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(bizAppDataReportService.deleteBizAppDataReportByBaseIds(baseIds));
    }
    /**
     * 数据报告统计
     */
    //@PreAuthorize("@ss.hasPermi('system:report:statistic')")
    @GetMapping("/statistic")
    public AjaxResult statistic(BizAppDataReport bizAppDataReport)
    {
        List<BizAppDataReport> list = bizAppDataReportService.dataReportStatistic(bizAppDataReport);
        return success(list);
    }
}
